home *** CD-ROM | disk | FTP | other *** search
- package com.extensibility.xml;
-
- import java.awt.Toolkit;
- import java.util.Enumeration;
- import java.util.Vector;
-
- public class SchemaValidator implements Runnable {
- boolean exitNow = false;
- Vector dirtyDecls = new Vector();
- SchemaIntf schema;
- boolean schemaDirty;
-
- public SchemaValidator(SchemaIntf var1) {
- this.schema = var1;
- }
-
- public void run() {
- try {
- Object var1 = null;
-
- while(true) {
- BaseDeclaration var4 = this.getNextDecl();
- if (this.exitNow) {
- this.dirtyDecls = null;
- return;
- }
-
- if (var4 == null) {
- this.schema.checkForErrors((BaseDeclaration)null);
- } else {
- boolean var2 = var4.hasErrors();
- this.schema.checkForErrors(var4);
- if (var2 != var4.hasErrors()) {
- var4.fireChangeEvent(99, (Object)null);
- }
- }
- }
- } catch (RuntimeException var3) {
- Toolkit.getDefaultToolkit().beep();
- ((Throwable)var3).printStackTrace();
- throw var3;
- }
- }
-
- private synchronized BaseDeclaration getNextDecl() {
- try {
- while(!this.exitNow) {
- if (!this.dirtyDecls.isEmpty()) {
- BaseDeclaration var4 = (BaseDeclaration)this.dirtyDecls.lastElement();
- this.dirtyDecls.removeElementAt(this.dirtyDecls.size() - 1);
- return var4;
- }
-
- if (this.schemaDirty) {
- this.schemaDirty = false;
- Object var1 = null;
- return (BaseDeclaration)var1;
- }
-
- this.wait();
- }
-
- Object var5 = null;
- return (BaseDeclaration)var5;
- } catch (InterruptedException var3) {
- return null;
- }
- }
-
- public synchronized void exit() {
- this.exitNow = true;
- this.notifyAll();
- }
-
- public synchronized void addAll() {
- this.removeAll();
- this.add(this.schema.getDeclarations());
- }
-
- public synchronized void addAll(URI var1) {
- this.add(this.schema.getDeclarations(var1, false));
- }
-
- public synchronized void checkAll() {
- this.removeAll();
- boolean var1 = false;
- Enumeration var2 = this.schema.getDeclarations();
-
- while(var2.hasMoreElements()) {
- BaseDeclaration var3 = (BaseDeclaration)var2.nextElement();
- boolean var4 = var3.hasErrors();
- var1 |= var4;
- this.schema.checkForErrors(var3);
- if (var4 != var3.hasErrors()) {
- var3.fireChangeEvent(99, (Object)null);
- }
- }
-
- this.schema.checkForErrors((BaseDeclaration)null);
- if (this.schema.getParseErrors().size() > 0) {
- var1 = true;
- }
-
- if (!var1 && this.schema.isSupported("GESTALT_SECOND_PASS_VALIDATION")) {
- this.schema.doSecondPassValidation((URI)null);
- }
-
- this.schemaDirty = false;
- }
-
- private synchronized void add(Enumeration var1) {
- while(var1.hasMoreElements()) {
- BaseDeclaration var2 = (BaseDeclaration)var1.nextElement();
- this.dirtyDecls.addElement(var2);
- }
-
- this.schemaDirty = true;
- this.notifyAll();
- }
-
- public synchronized void add(BaseDeclaration var1) {
- if (this.check(var1)) {
- this.schemaDirty = true;
- this.notifyAll();
- }
-
- }
-
- private synchronized boolean check(BaseDeclaration var1) {
- if (!this.dirtyDecls.contains(var1)) {
- this.dirtyDecls.addElement(var1);
- this.notifyAll();
- return true;
- } else {
- return false;
- }
- }
-
- public synchronized void remove(BaseDeclaration var1) {
- this.dirtyDecls.removeElement(var1);
- }
-
- public synchronized void removeAll() {
- for(int var1 = this.dirtyDecls.size() - 1; var1 >= 0; --var1) {
- this.remove((BaseDeclaration)this.dirtyDecls.elementAt(var1));
- }
-
- }
-
- public synchronized boolean isDone() {
- return this.dirtyDecls.isEmpty() && !this.schemaDirty;
- }
- }
-